<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>登录</title>
<link rel="stylesheet" href="../layui/css/layui.css">
</head>
<body>
	<form id="myForm">
		<div class="layui-form-item">
			<div class="layui-input-block">
				<h2 style="color:red;">账户登录</h2>
			</div>
		</div>
		
		<div class="layui-form-item">
			<div class="layui-input-block">
				<input type="text" name="usersName" id="usersName" style="width:280px;border:none;border-bottom:1px solid #ccc;" required lay-verify="required"
					placeholder="请输入用户名称" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<input type="password" name="usersPassword" id="usersPassword" style="width:280px;border:none;border-bottom:1px solid #ccc;" required
					lay-verify="required" placeholder="请输入密码" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<a class="layui-btn" style="width:280px;border-radius:50px;background-color:red" id="li-ji-login">立即登录</a>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				还没有账号?<a href="regist.html" style="color:blue;">立即注册</a>
			</div>
		</div>
	</form>
	<script src="../layui/layui.js"></script>
	<script src="../res/js/jquery-1.10.2.js"></script>
	<script>
//Demo
layui.use(['laydate', 'laypage', 'layer', 'table', 'upload', 'element'], function(){
	var laydate = layui.laydate //日期
	  ,laypage = layui.laypage //分页
	  layer = layui.layer //弹层
	  ,table = layui.table //表格
	  ,upload = layui.upload //上传
	  ,element = layui.element; //元素操作
  
 var $ = layui.$;
 
 $("#li-ji-login").click(function(){
	 var usersName = $("#usersName").val();
	 var usersPassword = $("#usersPassword").val();
	 if((usersName == "" || usersName == null ) && (usersPassword == "" || usersPassword == null)){
		 layer.msg('用户名称和用户密码不能为空',{icon:5,time:1000,anim: 6});
	 }else if(usersName == "" || usersName == null){
		 layer.msg('用户名称不能为空!',{icon:5,time:1000,anim: 6});
	 }else if(usersPassword == "" || usersPassword == null){
		 layer.msg('用户密码不能为空!',{icon:5,time:1000,anim: 6});
	 }else {
		 var url = "../user/isLogin.action";
		 var data = $("#myForm").serialize();
		 $.ajax({
			 url:url,
			 data:data,
			 success:function(msg){
				 if(msg.state == 1){
					 parent.location.reload();
				 }else {
					$("#usersName").val("");
					 $("#usersPassword").val("");
					 layer.msg(msg.msg+" 用户名或密码有错误!",{icon:5,time:1000});
				 }
			 }
		 });
	 }
	 
 });
});
</script>
</body>
</html>